package com.tianhao.luo.nouse.v1.director;

import com.tianhao.luo.nouse.v1.builder.ProductBuilder;
import com.tianhao.luo.nouse.v1.product.Product;

/**
 * 控制构建顺序的类，这是一个中介者
 * @author tianhao.luo
 * @date 2019/12/11 14:03
 */
public class Director {
    /**
     * 有一个构造着接口对象作为属性
     */
    private ProductBuilder builder;

    public Director(ProductBuilder builder) {
        this.builder = builder;
    }

    /**
     * 控制生产产品的流程
     */
    public Product makeProduct(String productName, String companyName, String part1, String part2, String part3, String part4) {
        //流程由自己指定
        builder.builderProductName(productName);
        builder.builderCompanyName(companyName);
        builder.builderPart1(part1);
        builder.builderPart2(part2);
        builder.builderPart3(part3);
        builder.builderPart4(part4);
        //组装产品对象
        return builder.build();

    }
}
